using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using SimpleSaas.Common;
using SimpleSaas.Web.Common;

namespace SimpleSaasAuth
{
	public class Program
	{
		public static void Main(string[] args)
		{
			var builder = WebApplication.CreateBuilder(args);

			// Add services to the container.

			//使用第三方工厂
			builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());

			//支持windows服务发布

			Startup startup = new Startup(builder.Configuration);


			App.Configuration = builder.Configuration;

			builder.Host.UseWindowsService();

			startup.ConfigureServices(builder.Services);

			builder.Host.ConfigureContainer<ContainerBuilder>((builder) =>
			{
				startup.ConfigureContainer(builder);
			});

			builder.Services.AddControllers();

			var app = builder.Build();

			startup.Configure(app, app.Environment);

			app.Run();
		}
	}
}